﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;

namespace Common.DataBaseNew
{
    [DataContract]
    public class DataBase
    {
        [DataMember]
        private SortedDictionary<int, Forum> forums;
        [DataMember]
        private User director;
        [DataMember]
        private int idforForums;

        public DataBase(User director) {
            this.director = director;
            this.forums = new SortedDictionary<int, Forum>();
            this.idforForums = 0;
        }

        public void setIdForForums(int num) {
            this.idforForums = num;
        }
        //Create new forum. In success return forum id.
        public int addForum(string title, User admin) {
            idforForums += 1;
            Forum forum = new Forum(idforForums, title, admin);
            forum.registerUser(this.director);
            forums.Add(idforForums, forum);
            return idforForums;  
        }

        public SortedDictionary<int, Forum> getForums() { 
            return this.forums;
        }

        public Forum getForum(int forumId)
        {
            if (forums.ContainsKey(forumId))
                return forums[forumId];
            else
                return null;
        }

        public User getDirector(){
            return this.director;
        }
    }
}
